package com.sinosoft.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sinosoft.base.BaseFormController;
import com.sinosoft.base.Constants;
import com.sinosoft.product.ChangeImage;
import com.sinosoft.product.ProductSearchManager;
import com.sinosoft.product.ZywxImage;

@Controller
@RequestMapping("/scene/sceneview.html")
public class SceneViewController extends BaseFormController {
	ProductSearchManager productmgr;
	
	@Autowired
	public void setProductmgr(ProductSearchManager productmgr) {
		this.productmgr = productmgr;
	}

	/**
	 * 查看景信息
	 * @param map
	 * @param request
	 * @return
	 */
	@RequestMapping(params="method=view")
	public String getScene(ModelMap map,HttpServletRequest request)
	{
		String tasktype = request.getParameter("tasktype");
		String sceneid = request.getParameter("sceneid");
		String productid = request.getParameter("productid");
		String productlevel = request.getParameter("productlevel");
		String satelliteid = request.getParameter("satelliteid");
		String sensorid = request.getParameter("sensorid");
		if(tasktype!=null && tasktype.equals("1"))
		{
			productlevel = Constants.LEVEL0_SCENE;
		}
		String modelname = ChangeImage.getModelName(productlevel);
		Object obj = productmgr.getZywxImageModel(productlevel, satelliteid, sensorid, productid, sceneid, modelname);
		ZywxImage image = ChangeImage.ImageToImage(obj);
		map.addAttribute("Image",image);
		if(productlevel.equalsIgnoreCase(Constants.LEVEL0_SCENE))
		{
			return "product/sceneviewlevel0";
		}
		else
		{
			return "product/sceneviewlevel1";
		}
	}
}
